package com.xyht.sca_s.student_manage_system.modules.clockIn.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xyht.sca_s.student_manage_system.common.commonReturn.CommonCodeEnum;
import com.xyht.sca_s.student_manage_system.common.commonReturn.CommonResult;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.util.CacheUtil;
import com.xyht.sca_s.student_manage_system.common.util.TimeUtil;
import com.xyht.sca_s.student_manage_system.modules.clockIn.entity.*;
import com.xyht.sca_s.student_manage_system.modules.clockIn.entity.req.SmsClockInReq;
import com.xyht.sca_s.student_manage_system.modules.clockIn.entity.resp.*;
import com.xyht.sca_s.student_manage_system.modules.clockIn.mapper.*;
import com.xyht.sca_s.student_manage_system.modules.clockIn.service.SmsClockInService;
import com.xyht.sca_s.student_manage_system.modules.clockIn.until.GeoUtil;
import com.xyht.sca_s.student_manage_system.modules.user.entity.SmsUser;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import static com.xyht.sca_s.student_manage_system.common.util.ParamCheckUtil.isNullOrEmpty;
import static com.xyht.sca_s.student_manage_system.modules.clockIn.constant.ClockInStateConstant.*;
import static com.xyht.sca_s.student_manage_system.modules.clockIn.constant.ClockInTypeConstant.CLOCK_IN_TYPE_END;
import static com.xyht.sca_s.student_manage_system.modules.clockIn.constant.ClockInTypeConstant.CLOCK_IN_TYPE_START;

/**
 * <p>
 * 打卡记录表 服务实现类
 * </p>
 *
 * @author XYHT
 * @since 2023-08-03
 */
@Service
public class SmsClockInServiceImpl extends ServiceImpl<SmsClockInMapper, SmsClockIn> implements SmsClockInService {

    @Resource
    private SmsClockInMapper clockInMapper;
    @Resource
    private SmsClockInGroupSettingMapper groupSettingMapper;
    @Resource
    private SmsClockInGpsSettingMapper gpsSettingMapper;
    @Resource
    private SmsClockInClassesSettingMapper classesSettingMapper;
    @Resource
    private CacheUtil cacheUtil;
    @Resource
    private SmsClockInGroupUserRelationMapper groupUserRelationMapper;


    @Override
    public ResponseResult getClockInInfo(String userId,String clockInLongitude,String clockInLatitude,String clockInDate) {

        if(isNullOrEmpty(clockInDate)){
            return CommonResult.failed(CommonCodeEnum.INVALID_PARAM);
        }
        SmsClockInInfoResp clockInInfoResp = new SmsClockInInfoResp();
        //考勤人信息
        SmsUser userInfo = cacheUtil.getUserInfo(userId);
        if (userInfo != null) {
            SmsClockInUserResp clockInUserResp = new SmsClockInUserResp();
            BeanUtils.copyProperties(userInfo, clockInUserResp);
            clockInInfoResp.setClockInUserInfo(clockInUserResp);
        }
//        //校验考勤组是否有自己
//        List<SmsClockInGroupSetting> groupSettings = groupSettingMapper.selectList(new LambdaQueryWrapper<SmsClockInGroupSetting>()
//                .orderByDesc(SmsClockInGroupSetting::getUpdateObjectIdTime))
//                .stream()
//                .filter(groupSetting -> {
//                    //校验选取个人时
//                    if (groupSetting.getClockInObjectType() == CLOCK_IN_OBJECT_TYPE_PERSON) {
//                        List<String> objectIdList = JSONObject.parseArray(groupSetting.getClockInObjectId(), String.class);
//                        return objectIdList.contains(userId);
//                        //校验选取角色时
//                    } else if (groupSetting.getClockInObjectType() == CLOCK_IN_OBJECT_TYPE_ROLE) {
//                        List<String> objectIdList = JSONObject.parseArray(groupSetting.getClockInObjectId(), String.class);
//                        List<String> roleList = cacheUtil.getRoleList(userId);
//                        return roleList.stream().filter(objectIdList::contains).collect(Collectors.toSet()).size() >= 1;
//                        //校验选取组织时
//                    } else if (groupSetting.getClockInObjectType() == CLOCK_IN_OBJECT_TYPE_ORG) {
//                        List<String> objectIdList = JSONObject.parseArray(groupSetting.getClockInObjectId(), String.class);
//                        List<String> orgList = cacheUtil.getOrgList(userId);
//                        return orgList.stream().filter(objectIdList::contains).collect(Collectors.toSet()).size() >= 1;
//                    }
//                    return true;
//                }).collect(Collectors.toList());
        //校验考勤组是否有自己
        List<SmsClockInGroupUserRelation> groupUserRelations = groupUserRelationMapper.selectList(null)
                .stream()
                .filter(groupUserRelation -> {
                    if (groupUserRelation.getUserId().equals(userId)) {
                        return true;
                    }
                    return false;
                }).collect(Collectors.toList());
        if(groupUserRelations.size() > 0) {
            SmsClockInGroupUserRelation groupUserRelation = groupUserRelations.get(0);
            //查询班次设置
            List<SmsClockInClassesSetting> classesSettings = classesSettingMapper.selectList(new LambdaQueryWrapper<SmsClockInClassesSetting>()
                    .eq(SmsClockInClassesSetting::getClockInGroupId, groupUserRelation.getClockInGroupId()));
            //查询GPS设置
            List<SmsClockInGpsSetting> gpsSettings = gpsSettingMapper.selectList(new LambdaQueryWrapper<SmsClockInGpsSetting>()
                    .eq(SmsClockInGpsSetting::getClockInGroupId, groupUserRelation.getClockInGroupId()));
            //查询打卡信息是否有
            List<SmsClockIn> smsClockInList = clockInMapper.selectList(new LambdaQueryWrapper<SmsClockIn>()
                    .eq(SmsClockIn::getClockInDate, clockInDate)
                    .eq(SmsClockIn::getClockInGroupId, groupUserRelation.getClockInGroupId()));
            if (classesSettings != null && classesSettings.size() > 0) {
                clockInInfoResp.setIsWork(false);
                for (SmsClockInClassesSetting classesSetting : classesSettings) {
                    //获取当前周几(0-6 代表周日到周六)
                    Integer nowWeekday = TimeUtil.StringtoDate(clockInDate).getDay();
                    //校验当前周几与班次设置周几一样,并且启用
                    if (classesSetting.getWeekday().equals(nowWeekday) && classesSetting.getIsUse()) {
                        clockInInfoResp.setIsWork(true);
                        clockInInfoResp.setClockInGroupId(groupUserRelation.getClockInGroupId());//考勤组di

                        if (gpsSettings != null && gpsSettings.size() > 0) {
                            //GPS考勤id
                            clockInInfoResp.setGpsId(gpsSettings.stream().map(SmsClockInGpsSetting::getId).collect(Collectors.toList()));

                            //有 则返回打卡数据
                           if (!isNullOrEmpty(clockInLongitude) && !isNullOrEmpty(clockInLatitude)) {//校验地理位置
                                double longitude = new Double(clockInLongitude);
                                double latitude = new Double(clockInLatitude);
                                boolean distanceFlag = false;
                                for (SmsClockInGpsSetting gpsSetting : gpsSettings) {
                                    double settingRange = (double) gpsSetting.getSettingRange();
                                    double settingLongitude = new Double(gpsSetting.getSettingLongitude());
                                    double settingInLatitude = new Double(gpsSetting.getSettingInLatitude());
                                    double distance = GeoUtil.distance(longitude, latitude, settingLongitude, settingInLatitude);
                                    if (distance < settingRange) {
                                        distanceFlag = true;
                                        clockInInfoResp.setAddressName(gpsSetting.getSettingAddressName());
                                        break;
                                    }
                                }
                                if (!distanceFlag) {//不在打卡范围内
                                    clockInInfoResp.setFlag(2);
                                }else {
                                    //可打卡
                                    clockInInfoResp.setFlag(1);
                                }
                            }else {
                                clockInInfoResp.setFlag(2);
                            }

                            clockInInfoResp.setStartHours(TimeUtil.TimeFormatSting(classesSetting.getStartHours()));//上班时间
                            clockInInfoResp.setEndHours(TimeUtil.TimeFormatSting(classesSetting.getEndHours()));//下班时间
                            clockInInfoResp.setClassesId(classesSetting.getId());//班次id
                            //打卡信息
                            List<SmsClockIn> smsClockIns = clockInMapper.selectList(new LambdaQueryWrapper<SmsClockIn>()
                                    .eq(SmsClockIn::getUserId, userId)
                                    .eq(SmsClockIn::getClockInDate, clockInDate));
                            List<SmsClockInStateResp> clockInStateList = new ArrayList<>();
                            clockInInfoResp.setClockInStateList(clockInStateList);
                            if (smsClockIns != null && smsClockIns.size() > 0) {
                                clockInStateList = smsClockIns.stream()
                                        .map(clockInInfo -> {
                                            SmsClockInStateResp clockInStateResp = new SmsClockInStateResp();
                                            BeanUtils.copyProperties(clockInInfo, clockInStateResp);
                                            String gpsId = clockInInfo.getGpsId();
                                            if (!isNullOrEmpty(gpsId)) {
                                                SmsClockInGpsSetting gpsSetting = gpsSettingMapper.selectById(gpsId);
                                                clockInStateResp.setAddressName(gpsSetting.getSettingAddressName());
                                            }
                                            clockInStateResp.setClockInDate(TimeUtil.DateSimpleformat(clockInInfo.getClockInDate()));
                                            if (!isNullOrEmpty(clockInInfo.getClockInTime())) {
                                                clockInStateResp.setClockInTime(TimeUtil.TimeAndSecFormat(clockInInfo.getClockInTime()));
                                            }
                                            if (!isNullOrEmpty(clockInInfo.getClockInDate())) {
                                                clockInStateResp.setClockInDate(TimeUtil.DateFormatSting(clockInInfo.getClockInDate()));
                                            }
                                            return clockInStateResp;
                                        })
                                        .collect(Collectors.toList());
                                clockInInfoResp.setClockInStateList(clockInStateList);
                            }

                        }
                    }
                }
            }
        }

        return CommonResult.success(clockInInfoResp);
    }

    @Override
    public ResponseResult startClockIn(String userId, SmsClockInReq smsClockInReq) {

        SmsClockInCommentResp clockInCommentResp = new SmsClockInCommentResp();
        double clockInLatitude = new Double(smsClockInReq.getClockInLatitude());//打卡时的纬度
        double clockInLongitude =new Double(smsClockInReq.getClockInLongitude());//打卡时的经度
        String clockInGroupId = smsClockInReq.getClockInGroupId();//考勤组id
        String classesId = smsClockInReq.getClassesId();//班次id
        String clockInHoursStr = smsClockInReq.getClockInTime();//打卡的时间
        if(isNullOrEmpty(clockInLatitude) || isNullOrEmpty(clockInLongitude) || isNullOrEmpty(clockInHoursStr)){
            return CommonResult.failed(CommonCodeEnum.INVALID_PARAM);
        }
        //校验
        Date clockInHours = TimeUtil.StringtoDate(clockInHoursStr);
        long millisecond = clockInHours.getTime() - new Date().getTime();
        if(millisecond/1000 > 5){
            return CommonResult.failed(CommonCodeEnum.INVALID_PARAM);
        }

        if(smsClockInReq.getGpsIdList() == null || smsClockInReq.getGpsIdList().size() < 1){
            return CommonResult.failed(CommonCodeEnum.INVALID_PARAM);
        }
        SmsClockInGroupSetting groupSetting = groupSettingMapper.selectById(clockInGroupId);
        if(groupSetting == null){
            return CommonResult.failed(CommonCodeEnum.CLOCK_IN_GROUP_NOT_EXIST);
        }
        List<SmsClockInGpsSetting> gpsSettings = gpsSettingMapper.selectList(new LambdaQueryWrapper<SmsClockInGpsSetting>()
                .eq(SmsClockInGpsSetting::getClockInGroupId, clockInGroupId)
                .in(SmsClockInGpsSetting::getId, smsClockInReq.getGpsIdList()));
        if(gpsSettings == null || gpsSettings.size() < 1){
            return CommonResult.failed(CommonCodeEnum.CLOCK_IN_GPS_NOT_EXIST);
        }
        SmsClockIn clockIn = new SmsClockIn();
        BeanUtils.copyProperties(smsClockInReq,clockIn);
        clockIn.setClockInTime(clockInHours);
        clockIn.setClockInDate(new Date());
        clockIn.setUserId(userId);
        //校验地理位置
        boolean distanceFlag = false;
        for (SmsClockInGpsSetting gpsSetting : gpsSettings) {
            double settingRange =(double) gpsSetting.getSettingRange();
            double settingLongitude = new Double(gpsSetting.getSettingLongitude());
            double settingInLatitude = new Double(gpsSetting.getSettingInLatitude());
            double distance = GeoUtil.distance(clockInLongitude,clockInLatitude,settingLongitude,settingInLatitude);
            if(distance < settingRange){
                clockIn.setGpsId(gpsSetting.getId());
               distanceFlag = true;
               break;
            }
        }
        if(!distanceFlag){//不在打卡范围内
            return CommonResult.failed(CommonCodeEnum.CLOCK_IN_NOT_RANGE);
        }

        //查询班次信息
        SmsClockInClassesSetting classesSetting = classesSettingMapper.selectOne(new LambdaQueryWrapper<SmsClockInClassesSetting>()
                .eq(SmsClockInClassesSetting::getId, classesId)
                .eq(SmsClockInClassesSetting::getClockInGroupId, clockInGroupId)
                .eq(SmsClockInClassesSetting::getIsUse, true));
        if (classesSetting == null) {
            return CommonResult.failed(CommonCodeEnum.CLOCK_IN_CLASSES_NOT_EXIST);
        }

        //获取考勤组限制设置信息
        Integer lateTimeLimit = classesSetting.getLateTimeLimit();//迟到时间限制(默认为0分钟)
        Integer startLackTimeLimit = classesSetting.getStartLackTimeLimit();//缺卡时间限制(默认为30分钟)
        Integer advanceTimeLimit = classesSetting.getAdvanceTimeLimit();//提前时间限制(默认为30分钟)

        //考勤组设置应上下班时间
        Date shouldStartHours = classesSetting.getStartHours(); //应上班时间
        Date shouldEndHours = classesSetting.getEndHours(); //应下班时间

        //判断当天有几次打卡
        Integer count = clockInMapper.selectCount(new LambdaQueryWrapper<SmsClockIn>()
                .eq(SmsClockIn::getUserId, userId)
                .ge(SmsClockIn::getClockInDate, TimeUtil.GetDate()));

        //如果count为0时,为上班卡
        int workFlag;
        if (count == 0) {
            workFlag = CLOCK_IN_TYPE_START;
            long differenceMil = 0;
            boolean flag = false;
            differenceMil = getDifferenceMin(clockInHours, shouldStartHours);
            //如果为负数.以及超出配置时间
            if (differenceMil < 0) {
                differenceMil = -differenceMil;
                flag = true;
            }
            //转为分钟差
            long nm = 1000 * 60;
            int differenceMin = (int) (differenceMil / nm);
            //上班卡
            clockIn.setClockInType(CLOCK_IN_TYPE_START);
            if (!flag) {//在固定打卡时间之后
                if (differenceMin >= lateTimeLimit) {
                    if (differenceMin >= startLackTimeLimit) {//缺卡
                        clockIn.setClockInState(CLOCK_IN_STATE_LACK);
                    } else {//迟到
                        clockIn.setClockInState(CLOCK_IN_STATE_LATE);
                    }
                } else {//正常打卡
                    clockIn.setClockInState(CLOCK_IN_STATE_NORMAL);
                }
            } else {//在固定打卡时间之前
                if (differenceMin > advanceTimeLimit) {//超出时间限制不允许提前打卡
                    return CommonResult.failed(CommonCodeEnum.CLOCK_IN_NOT_BEFORE_LIMIT_TIME);
                } else {//正常打卡
                    clockIn.setClockInState(CLOCK_IN_STATE_NORMAL);
                }
            }
            clockInMapper.insert(clockIn);
            //下班
        } else {
            workFlag = CLOCK_IN_TYPE_END;
            //下班时判断是修改打卡信息 还是新增
            List<SmsClockIn> clockInList = clockInMapper.selectList(new LambdaQueryWrapper<SmsClockIn>()
                    .eq(SmsClockIn::getUserId, userId)
                    .ge(SmsClockIn::getClockInDate, TimeUtil.GetDate()));
            for (SmsClockIn clockInfo : clockInList) {
                //1.修改下班打卡信息
                if (clockInfo.getClockInType() == CLOCK_IN_TYPE_END) {
                    clockIn.setId(clockInfo.getId());
                    SmsClockIn updateClockIn = getClockInState(clockInHours, shouldEndHours, clockIn, classesSetting);
                    if(updateClockIn.getClockInState() == CLOCK_IN_STATE_LEAVE_EARLY){
                        if(isNullOrEmpty(updateClockIn.getTakePicture()) && isNullOrEmpty(updateClockIn.getRemark())){
                            return CommonResult.failed(CommonCodeEnum.CLOCK_IN_ABNORMAL_REASON);
                        }
                    }
                    clockInMapper.updateById(updateClockIn);
                //2.新增下班打卡信息
                }else if(clockInfo.getClockInType() == CLOCK_IN_TYPE_START && clockInList.size() == 1){
                    SmsClockIn addClockIn = getClockInState(clockInHours, shouldEndHours, clockIn, classesSetting);
                    if(addClockIn.getClockInState() == CLOCK_IN_STATE_LEAVE_EARLY){
                        if(isNullOrEmpty(addClockIn.getTakePicture()) && isNullOrEmpty(addClockIn.getRemark())){
                            return CommonResult.failed(CommonCodeEnum.CLOCK_IN_ABNORMAL_REASON);
                        }
                    }
                    clockInMapper.insert(addClockIn);
                }
            }
        }
        clockInCommentResp.setClockInState(clockIn.getClockInState());
        String clockInfoKey = TimeUtil.DateSimpleformat(clockIn.getClockInDate())+"-"+ userId + "-" + workFlag;
        cacheUtil.add(clockInfoKey,"flag");
        return CommonResult.success(clockInCommentResp);
    }


    /**
     * 查看下班打卡状态
     * @param clockInHours 打卡时间
     * @param shouldEndHours 应该下班时间
     * @param clockInState 打卡信息
     * @param classesSetting 班次信息
     * @return 打卡状态信息
     */
    private SmsClockIn getClockInState(Date clockInHours, Date shouldEndHours,SmsClockIn clockInState,SmsClockInClassesSetting classesSetting){
        long differenceMil = 0;
        //早退时间限制(默认为0分钟)
        Integer leaveEarlyTimeLimit = classesSetting.getLeaveEarlyTimeLimit();
        //缺卡时间限制(默认为30分钟)
        Integer endLackTimeLimit = classesSetting.getEndLackTimeLimit();
        boolean flag = false;
        differenceMil = getDifferenceMin(clockInHours, shouldEndHours);
        //如果为负数.以及超出配置时间
        if (differenceMil < 0) {
            differenceMil = -differenceMil;
            flag = true;
        }
        //转为分钟差
        long nm = 1000 * 60;
        int differenceMin = (int) (differenceMil / nm);
        //下班卡
        clockInState.setClockInType(CLOCK_IN_TYPE_END);
        if (flag) {
            if (differenceMin >= leaveEarlyTimeLimit) {
                if (differenceMin >= endLackTimeLimit) {//缺卡
                    clockInState.setClockInState(CLOCK_IN_STATE_LACK);
                } else {//早退
                    clockInState.setClockInState(CLOCK_IN_STATE_LEAVE_EARLY);
                }
            } else {//正常
                clockInState.setClockInState(CLOCK_IN_STATE_NORMAL);
            }
        } else {//正常
            clockInState.setClockInState(CLOCK_IN_STATE_NORMAL);
        }

        return clockInState;
    }

    private long getDifferenceMin(Date clockInHours,Date limitDate) {
        //打卡时的年月日转为一致,方便对比
        clockInHours.setYear(limitDate.getYear());
        clockInHours.setMonth(limitDate.getMonth());
        clockInHours.setDate(limitDate.getDate());
        long nowMil = clockInHours.getTime();
        long limitMil = limitDate.getTime();
        //毫秒差
        return nowMil - limitMil;
    }

    @Override
    public ResponseResult getThisMonthStatistics(String userId,String clockInDate,Integer clockInState) {

        if(isNullOrEmpty(clockInDate)){
            return CommonResult.failed(CommonCodeEnum.INVALID_PARAM);
        }
        //转化格式
        Date date = TimeUtil.StringtoDate(clockInDate);
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        //查传入这个月的一号
        cal.set(Calendar.DAY_OF_MONTH, 1);
        String firstDate = TimeUtil.DateFormatSting(cal.getTime());
        //查传入这个月的最后一号
        cal.roll(Calendar.DAY_OF_MONTH, -1);
        String endDate = TimeUtil.DateFormatSting(cal.getTime());

        SmsClockInThisMonthStatisticsResp thisMonthStatisticsResp = new SmsClockInThisMonthStatisticsResp();
        List<SmsClockInDateAndStateResp> clockInDateAndStateList = new ArrayList<>();
        //查看当月每天的打卡情况
       LambdaQueryWrapper<SmsClockIn> queryWrapper = new LambdaQueryWrapper<>();
       if(!isNullOrEmpty(clockInState)){
           queryWrapper.eq(SmsClockIn::getClockInState,clockInState);
       }
       queryWrapper.eq(SmsClockIn::getUserId, userId)
               .ge(SmsClockIn::getClockInDate, firstDate)
               .le(SmsClockIn::getClockInDate, endDate);
        List<SmsClockIn> clockInList = clockInMapper.selectList(queryWrapper);
        if(!clockInList.isEmpty()){
            clockInDateAndStateList = clockInList
                    .stream()
                    .map(clockIn -> {
                        SmsClockInDateAndStateResp dateAndStateResp = new SmsClockInDateAndStateResp();
                        dateAndStateResp.setWeekDay(TimeUtil.getWeek(clockIn.getClockInDate()));
                        dateAndStateResp.setClockInDate(TimeUtil.DateFormatSting(clockIn.getClockInDate()));
                        dateAndStateResp.setClockInState(clockIn.getClockInState());
                        return dateAndStateResp;
                    })
                    .collect(Collectors.toList());
        }
        thisMonthStatisticsResp.setClockInDateAndStateList(clockInDateAndStateList);
        //正常出勤
        Integer normalCount = clockInMapper.selectCount(new LambdaQueryWrapper<SmsClockIn>()
                .eq(SmsClockIn::getUserId, userId)
                .eq(SmsClockIn::getClockInState, CLOCK_IN_STATE_NORMAL)
                .ge(SmsClockIn::getClockInDate, firstDate)
                .le(SmsClockIn::getClockInDate, endDate));

        //迟到
        Integer lateCount = clockInMapper.selectCount(new LambdaQueryWrapper<SmsClockIn>()
                .eq(SmsClockIn::getUserId, userId)
                .eq(SmsClockIn::getClockInState, CLOCK_IN_STATE_LATE)
                .ge(SmsClockIn::getClockInDate, firstDate)
                .le(SmsClockIn::getClockInDate, endDate));
        //早退
        Integer leaveEarlyClockInCount = clockInMapper.selectCount(new LambdaQueryWrapper<SmsClockIn>()
                .eq(SmsClockIn::getUserId, userId)
                .eq(SmsClockIn::getClockInState, CLOCK_IN_STATE_LEAVE_EARLY)
                .ge(SmsClockIn::getClockInDate, firstDate)
                .le(SmsClockIn::getClockInDate, endDate));
        //缺卡
        Integer lackClockInCount = clockInMapper.selectCount(new LambdaQueryWrapper<SmsClockIn>()
                .eq(SmsClockIn::getUserId, userId)
                .eq(SmsClockIn::getClockInState, CLOCK_IN_STATE_LACK)
                .ge(SmsClockIn::getClockInDate, firstDate)
                .le(SmsClockIn::getClockInDate, endDate));


        thisMonthStatisticsResp.setNormalCount(normalCount);
        thisMonthStatisticsResp.setLateCount(lateCount);
        thisMonthStatisticsResp.setLeaveEarlyCount(leaveEarlyClockInCount);
        thisMonthStatisticsResp.setLackCount(lackClockInCount);

        return CommonResult.success(thisMonthStatisticsResp);
    }

}
